import ThreadPool
import VariablePool
import Collector
from Collector import *
from Variable import *


def RTControlInit(threadcount = 5, timeout = None):
    ThreadPool.threadpool = ThreadPool.ThreadPool(threadcount, timeout)
    VariablePool.varpool = VariablePool.VariablePool()
    Collector.collmanager = CollectorManager()
    
    ThreadPool.threadpool.Start()
    
def RTControlExit():
    if Collector.collmanager:
        Collector.collmanager.WaitComplete()
        
    if ThreadPool.threadpool:
        ThreadPool.threadpool.Stop()
        
def AddCollector(obj):
    Collector.collmanager.AddCollector(obj)
    
def AddTask(callobj, *args, **kwargs):
    ThreadPool.threadpool.AddTask(callobj, *args, **kwargs)
